<?php

class Validator_controller extends CI_Controller{

    function __construct(){
        parent::__construct();
        $this->load->library('session');
        $this->load->helper('url');
        $this->load->helper('utils');
        
        Validator::is_access($this->session->userdata('user_id'));
    }

    function ajax_callfunction(){
        $objectfunction = $this->input->post('FUNC');
        $val_num = $this->input->post('VAL_NUM');

        $agrs = array();
        for($i=0; $i<$val_num; $i++){
            switch($this->input->post('VAL'.$i)){
                case 'null':
                    $agrs[] = NULL;
                    break;
                case 'true':
                    $agrs[] = TRUE;
                    break;
                case 'false':
                    $agrs[] = FALSE;
                    break;
                default:
                    $agrs[] = $this->input->post('VAL'.$i);
            }
        }
        $val = new Validator();
        echo $val->callFunction($objectfunction, $agrs);
        die();
    }

}